home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume0 / awm / part06 < prev    next >
Encoding:
Internet Message Format  |  1988-08-09  |  47.5 KB

  1. Path: uunet!wyse!mikew
  2. From: mikew@wyse.wyse.com (Mike Wexler)
  3. Newsgroups: comp.sources.x
  4. Subject: v00i007:  Ardent Window Manager(X11), Part06/13
  5. Message-ID: <1630@wyse.wyse.com>
  6. Date: 10 Aug 88 00:17:56 GMT
  7. Sender: news@wyse.wyse.com
  8. Lines: 1449
  9. Approved: mikew@wyse.com
  10.  
  11. Submitted-by: jkh@ardent (Jordan Hubbard)
  12. Posting-number: Volume 0, Issue 7
  13. Archive-name: awm/part06
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 6 (of 13)."
  22. # Contents:  awm/Icons.c awm/Makefile.rtl awm/NewIconify.c
  23. #   awm/RubberBand.c
  24. # Wrapped by mikew@wyse on Mon Aug  8 12:01:44 1988
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f awm/Icons.c -a "${1}" != "-c" ; then 
  27.   echo shar: Will not over-write existing file \"awm/Icons.c\"
  28. else
  29. echo shar: Extracting \"awm/Icons.c\" \(10429 characters\)
  30. sed "s/^X//" >awm/Icons.c <<'END_OF_awm/Icons.c'
  31. X#ident   "%W% %G%"
  32. X
  33. X
  34. X
  35. X#ifndef lint
  36. Xstatic char *rcsid_Icons_c = "$Header: Icons.c,v 1.3 88/07/23 17:24:56 jkh Exp $";
  37. X#endif  lint
  38. X
  39. X#include "X11/copyright.h"
  40. X/*
  41. X *
  42. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  43. X *
  44. X * Copyright 1987 by Jordan Hubbard.
  45. X *
  46. X *
  47. X *                         All Rights Reserved
  48. X *
  49. X * Permission to use, copy, modify, and distribute this software and its
  50. X * documentation for any purpose and without fee is hereby granted,
  51. X * provided that the above copyright notice appear in all copies and that
  52. X * both that copyright notice and this permission notice appear in
  53. X * supporting documentation, and that the name of Ardent Computer
  54. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  55. X * pertaining to distribution of the software without specific, written
  56. X * prior permission.
  57. X *
  58. X */
  59. X
  60. X/*
  61. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  62. X *
  63. X *                         All Rights Reserved
  64. X *
  65. X * Permission to use, copy, modify, and distribute this software and its
  66. X * documentation for any purpose and without fee is hereby granted,
  67. X * provided that the above copyright notice appear in all copies and that
  68. X * both that copyright notice and this permission notice appear in
  69. X * supporting documentation, and that the name of Digital Equipment
  70. X * Corporation not be used in advertising or publicity pertaining to
  71. X * distribution of the software without specific, written prior permission.
  72. X *
  73. X *
  74. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  75. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  76. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  77. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  78. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  79. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  80. X * SOFTWARE.
  81. X */
  82. X
  83. X
  84. X/*
  85. X * MODIFICATION HISTORY
  86. X *
  87. X * 000 -- L. Guarino Reid, DEC Ultrix Engineering Group
  88. X * 001 -- Jordan Hubbard, Ardent Computer
  89. X *  Many modifications for titled windows.
  90. X * 1.2 -- Jordan Hubbard, Ardent Computer.
  91. X * vPad and hPad usage corrected (Chris Thewalt fix).
  92. X * Clipping now set on right GC. 
  93. X * 1.3 -- Changed the way icon button events are handled.
  94. X */
  95. X#include "awm.h"
  96. X#include "X11/Xutil.h"
  97. X
  98. Xextern XContext AwmContext;
  99. X
  100. X/* the client should pass us a bitmap (single-plane pixmap with background=0
  101. X * and foreground = 1).  It is our responsibility to convert it to a pixmap
  102. X * of the appropriate depth for a window tile and also color it with the
  103. X * appropriate background and foreground pixels.
  104. X *
  105. X * we'll use the (global) IconGC for the fore/background pixels.
  106. X */
  107. X
  108. Xstatic Pixmap MakePixmapFromBitmap( bitmap, clipmask, width_return, height_return )
  109. XPixmap bitmap, clipmask;
  110. Xunsigned int *width_return, *height_return;
  111. X{
  112. X     Pixmap tile;
  113. X     Window junkW;
  114. X     int junk, width, height;
  115. X     GC iGC;
  116. X     XGCValues gcv;
  117. X     
  118. X     Entry("MakePixmapFromBitmap")
  119. X      
  120. X     if (!XGetGeometry( dpy, bitmap, &junkW, &junk, &junk,
  121. X               &width, &height, &junk, &junk )) {
  122. X      Warning( "client passed invalid pixmap for icon." );
  123. X      Leave( NULL )
  124. X     }
  125. X     tile = XCreatePixmap( dpy, RootWindow(dpy, scr), width, height,
  126. X              DefaultDepth(dpy, scr) );
  127. X     gcv.foreground = ITextForeground;
  128. X     gcv.background = ITextBackground;
  129. X     iGC = XCreateGC(dpy, RootWindow(dpy, scr), (GCForeground | GCBackground),
  130. X             &gcv);
  131. X     if (clipmask)
  132. X      XSetClipMask(dpy, iGC, clipmask);
  133. X     XCopyPlane(dpy, bitmap, tile, iGC, 0, 0, width, height, 0, 0, 1 );
  134. X     XFreeGC(dpy, iGC);
  135. X     if (width_return)
  136. X      *width_return = width;
  137. X     if (height_return)
  138. X      *height_return = height;
  139. X     Leave(tile)
  140. X}
  141. X
  142. Xchar *GetIconName(window)
  143. XWindow window;
  144. X{
  145. X     char *name;
  146. X     Status status;
  147. X     long len, after;
  148. X     Atom a_type;
  149. X     int a_form;
  150. X     
  151. X     Entry("GetIconName")
  152. X     
  153. X     status = XGetWindowProperty(dpy, window, XA_WM_ICON_NAME, 0, 256,
  154. X                 False, XA_STRING, &a_type, &a_form, &len, &after,
  155. X                 &name);
  156. X     
  157. X     if (status != Success) {
  158. X      status = XGetWindowProperty(dpy, window, XA_WM_NAME, 0, NAME_LEN,
  159. X                      False, XA_STRING, &a_type, &a_form, &len,
  160. X                      &after, &name);
  161. X      if (status != Success)
  162. X           Leave((char *)NULL)
  163. X     }
  164. X     if (a_form == 0)    /* we have no bananas */
  165. X      Leave((char *)NULL)
  166. X     if (a_form != 8) {
  167. X      Warning("Window has icon_name in wrong format");
  168. X      if (name)
  169. X           free(name);
  170. X      Leave((char *)NULL)
  171. X     }
  172. X     if (len > NAME_LEN) {
  173. X      Warning("Window has icon_name greater than maximum length");
  174. X      len = NAME_LEN;
  175. X     }
  176. X     if (!len)
  177. X      Leave((char *)NULL)
  178. X     name[len] = 0;
  179. X     Leave(name)
  180. X}
  181. X
  182. XBoolean IsIcon(icon, win)
  183. XWindow icon;
  184. XWindow *win;
  185. X{
  186. X     AwmInfoPtr awi;
  187. X
  188. X     Entry("IsIcon")
  189. X
  190. X     if (win)
  191. X      *win = 0;
  192. X     awi = GetAwmInfo(icon);
  193. X     if (!awi)
  194. X      Leave(FALSE)
  195. X     if (awi->icon == icon) {
  196. X      if (win)
  197. X           *win = awi->client;
  198. X      Leave(TRUE)
  199. X     }
  200. X     else if (awi->client == icon || awi->frame == icon) {
  201. X      if (win)
  202. X           *win = awi->icon;
  203. X      Leave(FALSE)
  204. X     }
  205. X     Leave(FALSE)
  206. X}
  207. X
  208. XRemoveIcon(window)
  209. XWindow window;
  210. X{
  211. X     AwmInfoPtr awi;
  212. X
  213. X     Entry("RemoveIcon")
  214. X     
  215. X     if ((awi = GetAwmInfo(window)) != NULL) {
  216. X      XDeleteContext(dpy, awi->icon, AwmContext);
  217. X      if (awi->own) {
  218. X           XDestroyWindow(dpy, awi->icon);
  219. X           if (awi->iconPixmap != IBackPixmap)
  220. X            XFreePixmap(dpy, awi->iconPixmap);
  221. X      }
  222. X      awi->icon = (Drawable)NULL;
  223. X      awi->state ^= ST_ICON;
  224. X      awi->state |= ST_WINDOW;
  225. X     }
  226. X     Leave_void
  227. X}
  228. X
  229. XGetDefaultSize(window, icon_w, icon_h)
  230. XWindow window;
  231. Xint *icon_w, *icon_h;
  232. X{
  233. X     char *name;                /* Event window name. */
  234. X
  235. X     Entry("GetDefaultSize")
  236. X
  237. X     /*
  238. X      * Determine the size of the icon window.
  239. X      */ 
  240. X     name = GetIconName(window);
  241. X     *icon_h = IFontInfo->ascent + IFontInfo->descent;
  242. X     if (name) {
  243. X      *icon_w = XTextWidth(IFontInfo, name, strlen(name));
  244. X      if (*icon_w == 0)
  245. X           *icon_w = *icon_h;
  246. X     }
  247. X     else 
  248. X      *icon_w = *icon_h;
  249. X     Leave_void
  250. X}
  251. X
  252. XWindow MakeIcon(window, x, y, mousePositioned)
  253. XWindow window;                          /* associated window. */
  254. Xint x, y;                               /* Event mouse position. */
  255. XBoolean mousePositioned;
  256. X{
  257. X     Window icon;            /* icon window. */
  258. X     int icon_x, icon_y;        /* Icon U. L. X and Y coordinates. */
  259. X     int icon_w, icon_h;        /* Icon width and height. */
  260. X     int icon_bdr;            /* Icon border width. */
  261. X     int mask;                /* Icon event mask */
  262. X     int depth;                /* for XGetGeometry */
  263. X     XSetWindowAttributes iconValues;    /* for icon window creation */
  264. X     unsigned long iconValues_mask;    /* for above */
  265. X     XWMHints *wmhints;            /* see if icon position provided */
  266. X     XWMHints *XGetWMHints();
  267. X     Pixmap clip = 0;
  268. X     Window AddIcon();
  269. X
  270. X     Entry("MakeIcon")
  271. X
  272. X     iconValues.background_pixmap = IBackPixmap;
  273. X     mask = (ExposureMask | StructureNotifyMask | KeyPressMask);
  274. X     /*
  275. X      * Process window manager hints.
  276. X      */ 
  277. X     if (wmhints = XGetWMHints(dpy, window)) {
  278. X      if (wmhints->flags & IconWindowHint)
  279. X           Leave(AddIcon(window, wmhints->icon_window, FALSE,
  280. X                 (StructureNotifyMask), (Pixmap)NULL))
  281. X      else if (wmhints->flags & IconPixmapHint) {
  282. X           if (wmhints->flags & IconMaskHint)
  283. X            clip = wmhints->icon_mask;
  284. X           iconValues.background_pixmap =
  285. X            MakePixmapFromBitmap(wmhints->icon_pixmap, clip,
  286. X                     &icon_w, &icon_h );
  287. X           if (iconValues.background_pixmap)
  288. X            mask = (StructureNotifyMask);
  289. X           else {
  290. X            iconValues.background_pixmap = IBackPixmap;
  291. X            wmhints->flags &= ~IconPixmapHint;
  292. X            GetDefaultSize(window, &icon_w, &icon_h);
  293. X           }
  294. X      }
  295. X      else GetDefaultSize(window, &icon_w, &icon_h);
  296. X     }
  297. X     else GetDefaultSize(window, &icon_w, &icon_h);
  298. X
  299. X     /*
  300. X      * Fix up sizes by padding.
  301. X      */
  302. X     if (!wmhints || !(wmhints->flags & (IconPixmapHint|IconWindowHint))) {
  303. X      icon_w += (HIconPad);
  304. X      icon_h += (VIconPad);
  305. X     }
  306. X
  307. X     /*
  308. X      * Set the icon border attributes.
  309. X      */ 
  310. X     if (!wmhints || !(wmhints->flags & IconWindowHint)) {
  311. X      icon_bdr = IBorderWidth;
  312. X      iconValues.border_pixel = IBorder;
  313. X     }
  314. X     if (wmhints && (wmhints->flags & IconPositionHint)) {
  315. X      icon_x = wmhints->icon_x;
  316. X      icon_y = wmhints->icon_y;
  317. X     } else {
  318. X      if (mousePositioned) {
  319. X           /*
  320. X        * Determine the coordinates of the icon window;
  321. X        * normalize so that we don't lose the icon off the
  322. X        * edge of the screen.
  323. X        */
  324. X           icon_x = x - (icon_w >> 1) + 1;
  325. X           if (icon_x < 0) icon_x = 0;
  326. X           icon_y = y - (icon_h >> 1) + 1;
  327. X           if (icon_y < 0) icon_y = 0;
  328. X           if ((icon_x - 1 + icon_w + (icon_bdr << 1)) > ScreenWidth) {
  329. X            icon_x = ScreenWidth - icon_w - (icon_bdr << 1) + 1;
  330. X           }
  331. X           if ((icon_y - 1 + icon_h + (icon_bdr << 1)) > ScreenHeight) {
  332. X            icon_y = ScreenHeight - icon_h - (icon_bdr << 1) + 1;
  333. X           }
  334. X      }
  335. X      else {
  336. X           icon_x = x + (icon_w >> 1);
  337. X           icon_y = y + (icon_y >> 1);
  338. X      }
  339. X      
  340. X     }
  341. X     
  342. X     /*
  343. X      * Create the icon window.
  344. X      */
  345. X     iconValues_mask = CWBorderPixel | CWBackPixmap;
  346. X     /*
  347. X      * Here we assume that if they want save unders, they'll also want
  348. X      * backing store on the icons. Perhaps a dangerous assumption, but
  349. X      * one we have to make at this point.
  350. X      */
  351. X     if (SaveUnder) {
  352. X      iconValues.backing_store = WhenMapped;
  353. X      iconValues_mask |= CWBackingStore;
  354. X     }
  355. X     Leave(AddIcon(window,
  356. X           XCreateWindow(
  357. X                 dpy, RootWindow(dpy, scr),
  358. X                 icon_x, icon_y,
  359. X                 icon_w, icon_h,
  360. X                 icon_bdr, 0, CopyFromParent, CopyFromParent,
  361. X                 iconValues_mask, &iconValues),
  362. X           TRUE, mask, iconValues.background_pixmap))
  363. X      
  364. X}
  365. X
  366. XWindow AddIcon(window, icon, own, mask, background)
  367. XWindow window, icon;
  368. XBoolean own;
  369. Xint mask;
  370. XPixmap background;
  371. X{
  372. X     Binding *bptr;
  373. X     AwmInfoPtr awi;
  374. X
  375. X     Entry("AddIcon")
  376. X
  377. X     if (icon == NULL)
  378. X      Leave(NULL)
  379. X     /*
  380. X      * Use the text cursor whenever the mouse is in the icon window.
  381. X      */
  382. X     XDefineCursor(dpy, icon, TextCursor);
  383. X     
  384. X     /*
  385. X      * Select "key pressed", "window exposure" and "unmap window"
  386. X      * events for the icon window.
  387. X      */
  388. X     XSelectInput(dpy, icon, mask | ButtonPressMask | ButtonReleaseMask);
  389. X
  390. X     awi = GetAwmInfo(window);
  391. X     awi->icon = icon;
  392. X     awi->own = own;
  393. X     awi->iconPixmap = background;
  394. X     XSaveContext(dpy, icon, AwmContext, awi);
  395. X     Leave(icon)
  396. X}
  397. END_OF_awm/Icons.c
  398. if test 10429 -ne `wc -c <awm/Icons.c`; then
  399.     echo shar: \"awm/Icons.c\" unpacked with wrong size!
  400. fi
  401. # end of overwriting check
  402. fi
  403. if test -f awm/Makefile.rtl -a "${1}" != "-c" ; then 
  404.   echo shar: Will not over-write existing file \"awm/Makefile.rtl\"
  405. else
  406. echo shar: Extracting \"awm/Makefile.rtl\" \(10660 characters\)
  407. sed "s/^X//" >awm/Makefile.rtl <<'END_OF_awm/Makefile.rtl'
  408. X# makefile generated by mkold
  409. X
  410. XXDIR = /usr/src/X.V11R2
  411. X
  412. XCOM.00 = $(XDIR)/lib
  413. XDIR.00 = $(COM.00)/oldX
  414. XDIR.01 = $(COM.00)/X
  415. X
  416. XNEATENOBJS =  \
  417. X    check_can_mod.o check_grow.o check_shrink.o \
  418. X    commit_op.o goal.o gravity.o mem.o state.o \
  419. X    tilwin_close.o tilwin_create.o tilwin_desk.o \
  420. X    tilwin_dump.o tilwin_init.o tilwin_list.o tilwin_misc.o \
  421. X    tilwin_open.o tilwin_resat.o tilwin_resize.o \
  422. X    tilwin_set.o tilwin_tmp.o tilwin_undo.o trial_grow.o \
  423. X    trial_place.o trial_satisfy.o trial_slide.o \
  424. X    tilwin_slide.o trial_edge_sweep.o win.o tilwin_thread.o \
  425. X    init_tws.o pieces_enum.o pieces_merge.o pieces_split.o \
  426. X    pieces_update.o tile_create.o tile_delete.o \
  427. X    tile_enlarge.o tile_find.o tile_nbrs.o tile_panic.o \
  428. X    tile_shrink.o tileopts.o userglobals.o neaten.o
  429. X
  430. Xneaten.a: $(NEATENOBJS)
  431. X    ar qcv neaten.a $(NEATENOBJS)
  432. X    ranlib neaten.a
  433. X
  434. Xcheck_can_mod.o : check_can_mod.c tilwin.extern.h state.extern.h \
  435. X        state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  436. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  437. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_can_mod.c
  438. X
  439. Xcheck_grow.o : check_grow.c win.extern.h tile.extern.h tile.h \
  440. X        basetype.h std_defs.h state.extern.h state.h \
  441. X        tilwin.intern.h tilwin.h tilwinopts.h tilwin.extern.h \
  442. X        tilwin.define.h tileopts.h copyright.h
  443. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_grow.c
  444. X
  445. Xcheck_shrink.o : check_shrink.c goal.extern.h tilwin.extern.h \
  446. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  447. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  448. X        tileopts.h
  449. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_shrink.c
  450. X
  451. Xcommit_op.o : commit_op.c win.extern.h tile.extern.h tile.h basetype.h \
  452. X        std_defs.h state.extern.h state.h tilwin.intern.h \
  453. X        tilwin.h tilwinopts.h tilwin.define.h tileopts.h
  454. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c commit_op.c
  455. X
  456. Xgoal.o : goal.c tilwin.define.h tileopts.h tilwin.intern.h tilwin.h \
  457. X        tilwinopts.h basetype.h std_defs.h copyright.h
  458. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c goal.c
  459. X
  460. Xgravity.o : gravity.c tilwin.extern.h state.extern.h state.h \
  461. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  462. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  463. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c gravity.c
  464. X
  465. Xmem.o : mem.c tile.h basetype.h std_defs.h tilwin.intern.h tilwin.h \
  466. X        tilwinopts.h copyright.h
  467. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c mem.c
  468. X
  469. Xstate.o : state.c tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  470. X        std_defs.h state.h copyright.h
  471. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c state.c
  472. X
  473. Xtilwin_close.o : tilwin_close.c state.extern.h state.h tilwin.intern.h \
  474. X        tilwin.h tilwinopts.h basetype.h std_defs.h win.extern.h \
  475. X        tilwin.define.h tileopts.h copyright.h
  476. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_close.c
  477. X
  478. Xtilwin_create.o : tilwin_create.c mem.extern.h state.extern.h state.h \
  479. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  480. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  481. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_create.c
  482. X
  483. Xtilwin_desk.o : tilwin_desk.c gravity.extern.h basetype.h std_defs.h \
  484. X        tile.extern.h tile.h tilwin.extern.h state.extern.h \
  485. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  486. X        copyright.h
  487. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_desk.c
  488. X
  489. Xtilwin_dump.o : tilwin_dump.c win.extern.h tilwin.extern.h \
  490. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  491. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  492. X        tileopts.h tile.extern.h tile.h tile.define.h \
  493. X        tile.intern.h copyright.h
  494. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_dump.c
  495. X
  496. Xtilwin_init.o : tilwin_init.c tile.intern.h tile.h basetype.h \
  497. X        std_defs.h tilwin.intern.h tilwin.h tilwinopts.h \
  498. X        copyright.h
  499. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_init.c
  500. X
  501. Xtilwin_list.o : tilwin_list.c state.extern.h state.h tilwin.intern.h \
  502. X        tilwin.h tilwinopts.h basetype.h std_defs.h \
  503. X        tilwin.define.h tileopts.h copyright.h
  504. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_list.c
  505. X
  506. Xtilwin_misc.o : tilwin_misc.c win.extern.h tile.extern.h tile.h \
  507. X        basetype.h std_defs.h tile.define.h tile.intern.h \
  508. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  509. X        tilwinopts.h tilwin.define.h tileopts.h copyright.h
  510. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_misc.c
  511. X
  512. Xtilwin_open.o : tilwin_open.c win.extern.h gravity.extern.h basetype.h \
  513. X        std_defs.h commit.extern.h trial.extern.h trial.h \
  514. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  515. X        tilwinopts.h tilwin.define.h tileopts.h copyright.h
  516. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_open.c
  517. X
  518. Xtilwin_resat.o : tilwin_resat.c win.extern.h commit.extern.h \
  519. X        trial.extern.h trial.h state.extern.h state.h \
  520. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  521. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  522. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_resat.c
  523. X
  524. Xtilwin_resize.o : tilwin_resize.c gravity.extern.h basetype.h \
  525. X        std_defs.h win.extern.h commit.extern.h trial.extern.h \
  526. X        trial.h state.extern.h state.h tilwin.intern.h tilwin.h \
  527. X        tilwinopts.h tilwin.define.h tileopts.h copyright.h
  528. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_resize.c
  529. X
  530. Xtilwin_set.o : tilwin_set.c trial.extern.h trial.h state.extern.h \
  531. X        state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  532. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  533. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_set.c
  534. X
  535. Xtilwin_tmp.o : tilwin_tmp.c trial.h state.extern.h state.h \
  536. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  537. X        std_defs.h trial.extern.h tilwin.define.h tileopts.h \
  538. X        copyright.h
  539. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_tmp.c
  540. X
  541. Xtilwin_undo.o : tilwin_undo.c win.extern.h state.extern.h state.h \
  542. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  543. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  544. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_undo.c
  545. X
  546. Xtrial_grow.o : trial_grow.c check.extern.h gravity.extern.h basetype.h \
  547. X        std_defs.h tilwin.extern.h state.extern.h state.h \
  548. X        tilwin.intern.h tilwin.h tilwinopts.h tilwin.define.h \
  549. X        tileopts.h copyright.h
  550. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_grow.c
  551. X
  552. Xtrial_place.o : trial_place.c check.extern.h gravity.extern.h \
  553. X        basetype.h std_defs.h tilwin.extern.h state.extern.h \
  554. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  555. X        tilwin.define.h tileopts.h copyright.h
  556. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_place.c
  557. X
  558. Xtrial_satisfy.o : trial_satisfy.c check.extern.h gravity.extern.h \
  559. X        basetype.h std_defs.h tilwin.extern.h state.extern.h \
  560. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  561. X        tilwin.define.h tileopts.h copyright.h
  562. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_satisfy.c
  563. X
  564. Xtrial_slide.o : trial_slide.c trial.extern.h trial.h tilwin.extern.h \
  565. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  566. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  567. X        tileopts.h copyright.h
  568. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_slide.c
  569. X
  570. Xtilwin_slide.o : tilwin_slide.c trial.extern.h trial.h tilwin.extern.h \
  571. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  572. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  573. X        tileopts.h copyright.h
  574. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_slide.c
  575. X
  576. Xtrial_edge_sweep.o : trial_edge_sweep.c tilwin.extern.h state.extern.h \
  577. X        state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  578. X        std_defs.h tile.extern.h tile.h tile.define.h \
  579. X        tile.intern.h copyright.h
  580. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_edge_sweep.c
  581. X
  582. Xwin.o : win.c gravity.extern.h basetype.h std_defs.h state.extern.h \
  583. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  584. X        tile.define.h tile.intern.h tile.h tile.extern.h \
  585. X        tilwin.define.h tileopts.h copyright.h
  586. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c win.c
  587. X
  588. Xtilwin_thread.o : tilwin_thread.c state.extern.h state.h \
  589. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  590. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  591. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_thread.c
  592. X
  593. Xinit_tws.o : init_tws.c tile-list.h tile.define.h tile.intern.h tile.h \
  594. X        basetype.h std_defs.h copyright.h
  595. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c init_tws.c
  596. X
  597. Xpieces_enum.o : pieces_enum.c tile.extern.h tile.h basetype.h \
  598. X        std_defs.h tile-list.h tile.define.h tile.intern.h \
  599. X        copyright.h
  600. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_enum.c
  601. X
  602. Xpieces_merge.o : pieces_merge.c tile-list.h tile.define.h tile.intern.h \
  603. X        tile.h basetype.h std_defs.h copyright.h
  604. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_merge.c
  605. X
  606. Xpieces_split.o : pieces_split.c tile.extern.h tile.h basetype.h \
  607. X        std_defs.h tile-list.h tile.define.h tile.intern.h \
  608. X        copyright.h
  609. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_split.c
  610. X
  611. Xpieces_update.o : pieces_update.c tile-list.h tile.define.h \
  612. X        tile.intern.h tile.h basetype.h std_defs.h copyright.h
  613. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_update.c
  614. X
  615. Xtile_create.o : tile_create.c tile.extern.h tile.h basetype.h \
  616. X        std_defs.h tile.define.h tile.intern.h copyright.h
  617. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_create.c
  618. X
  619. Xtile_delete.o : tile_delete.c tile.extern.h tile.h basetype.h \
  620. X        std_defs.h tile-list.h tile.define.h tile.intern.h \
  621. X        copyright.h
  622. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_delete.c
  623. X
  624. Xtile_enlarge.o : tile_enlarge.c tile.extern.h tile.h basetype.h \
  625. X        std_defs.h tile.define.h tile.intern.h copyright.h
  626. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_enlarge.c
  627. X
  628. Xtile_find.o : tile_find.c tilwin.extern.h state.extern.h state.h \
  629. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  630. X        std_defs.h tile.define.h tile.intern.h tile.h \
  631. X        copyright.h
  632. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_find.c
  633. X
  634. Xtile_nbrs.o : tile_nbrs.c tile-list.h tile.extern.h tile.h basetype.h \
  635. X        std_defs.h tile.define.h tile.intern.h
  636. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_nbrs.c
  637. X
  638. Xtile_panic.o : tile_panic.c copyright.h
  639. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_panic.c
  640. X
  641. Xtile_shrink.o : tile_shrink.c tile.define.h tile.intern.h tile.h \
  642. X        basetype.h std_defs.h copyright.h
  643. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_shrink.c
  644. X
  645. Xtileopts.o : tileopts.c tileopts.h basetype.h std_defs.h copyright.h
  646. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tileopts.c
  647. X
  648. Xuserglobals.o : userglobals.c explicitopts.h uservals.h useropts.h \
  649. X        basetype.h std_defs.h copyright.h
  650. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c userglobals.c
  651. X
  652. Xneaten.o : neaten.c neaten.define.h tilwin.define.h tileopts.h \
  653. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  654. X        std_defs.h userwin.define.h tilwin.extern.h \
  655. X        state.extern.h state.h userglobals.define.h userwin.h \
  656. X        explicitwinopts.h userwinopts.h 
  657. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c neaten.c
  658. END_OF_awm/Makefile.rtl
  659. if test 10660 -ne `wc -c <awm/Makefile.rtl`; then
  660.     echo shar: \"awm/Makefile.rtl\" unpacked with wrong size!
  661. fi
  662. # end of overwriting check
  663. fi
  664. if test -f awm/NewIconify.c -a "${1}" != "-c" ; then 
  665.   echo shar: Will not over-write existing file \"awm/NewIconify.c\"
  666. else
  667. echo shar: Extracting \"awm/NewIconify.c\" \(11181 characters\)
  668. sed "s/^X//" >awm/NewIconify.c <<'END_OF_awm/NewIconify.c'
  669. X#ident   "%W% %G%"
  670. X
  671. X
  672. X
  673. X#ifndef lint
  674. Xstatic char *rcsid_NewIconify_c = "$Header: NewIconify.c,v 1.2 88/07/23 17:24:56 jkh Exp $";
  675. X#endif  lint
  676. X
  677. X#include "X11/copyright.h"
  678. X/*
  679. X *
  680. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  681. X *
  682. X * Copyright 1987 by Jordan Hubbard.
  683. X *
  684. X *
  685. X *                         All Rights Reserved
  686. X *
  687. X * Permission to use, copy, modify, and distribute this software and its
  688. X * documentation for any purpose and without fee is hereby granted,
  689. X * provided that the above copyright notice appear in all copies and that
  690. X * both that copyright notice and this permission notice appear in
  691. X * supporting documentation, and that the name of Ardent Computer
  692. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  693. X * pertaining to distribution of the software without specific, written
  694. X * prior permission.
  695. X *
  696. X */
  697. X
  698. X/*
  699. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  700. X *
  701. X *                         All Rights Reserved
  702. X *
  703. X * Permission to use, copy, modify, and distribute this software and its
  704. X * documentation for any purpose and without fee is hereby granted,
  705. X * provided that the above copyright notice appear in all copies and that
  706. X * both that copyright notice and this permission notice appear in
  707. X * supporting documentation, and that the name of Digital Equipment
  708. X * Corporation not be used in advertising or publicity pertaining to
  709. X * distribution of the software without specific, written prior permission.
  710. X *
  711. X *
  712. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  713. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  714. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  715. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  716. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  717. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  718. X * SOFTWARE.
  719. X */
  720. X
  721. X/*
  722. X * MODIFICATION HISTORY
  723. X *
  724. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  725. X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
  726. X *  Western Software Lab. Port to X11.
  727. X */
  728. X
  729. X#include "awm.h"
  730. X
  731. XBoolean NewIconify(window, mask, button, x, y)
  732. XWindow window;                          /* Event window. */
  733. Xint mask;                               /* Button/key mask. */
  734. Xint button;                             /* Button event detail. */
  735. Xint x, y;                               /* Event mouse position. */
  736. X{
  737. X     XWindowAttributes fromInfo;    /* from window info. */
  738. X     XWindowAttributes toInfo;        /* to window info. */
  739. X     Window from, to;
  740. X     char *name;            /* Event window name. */
  741. X     int mse_x, mse_y;            /* Mouse X and Y coordinates. */
  742. X     int new_x, new_y;            /* To U. L. X and Y coordinates. */
  743. X     int new_w, new_h;            /* To width and height. */
  744. X     int bdw;                /* border width */
  745. X     int prev_x;            /* Previous event window X location. */
  746. X     int prev_y;            /* Previous event window Y location. */
  747. X     int cur_x;                /* Current event window X location. */
  748. X     int cur_y;                /* Current event window Y location. */
  749. X     int root_x;            /* Root window X location. */
  750. X     int root_y;            /* Root window Y location. */
  751. X     int ulx, uly;            /* Event window upper left X and Y. */
  752. X     int lrx, lry;            /* Event window lower right X and Y. */
  753. X     int init_ulx, init_uly;        /* Init window upper left X and Y. */
  754. X     int init_lrx, init_lry;        /* Init window lower right X and Y. */
  755. X     int num_vectors;            /* Number of vectors in box. */
  756. X     int status;                /* Routine call return status. */
  757. X     int ptrmask;            /* pointer query state. */
  758. X     Window root;            /* Mouse root window. */
  759. X     Window icon;            /* Icon window. */
  760. X     Window sub_win;            /* Mouse position sub-window. */
  761. X     XEvent button_event;        /* Button event packet. */
  762. X     XSegment box[MAX_BOX_VECTORS];    /* Box vertex buffer. */
  763. X     XSegment zap[MAX_ZAP_VECTORS];    /* Zap effect vertex buffer. */
  764. X     int (*storegrid_func)();        /* Function to use for grid */
  765. X     int (*storebox_func)();        /* Function to use for box */
  766. X     Boolean iconifying;        /* Are we iconifying? */
  767. X     AwmInfoPtr awi;
  768. X     
  769. X     Entry("NewIconify")
  770. X      
  771. X     /*
  772. X      * Do not lower or iconify the root window.
  773. X      */
  774. X     if (window == RootWindow(dpy, scr))
  775. X      Leave(FALSE)
  776. X     
  777. X     /*
  778. X      * Change the cursor to the icon cursor.
  779. X      */
  780. X     grab_pointer();
  781. X     
  782. X     /*
  783. X      * Clear the vector buffers.
  784. X      */
  785. X     bzero(box, sizeof(box));
  786. X     if (Zap)
  787. X      bzero(zap, sizeof(zap));
  788. X     
  789. X     /*
  790. X      * Get info on the event window.
  791. X      */
  792. X     awi = GetAwmInfo(window);
  793. X     if (!awi)
  794. X      Leave(FALSE)
  795. X     /*
  796. X      * Are we iconifying or de-iconifying?
  797. X      */
  798. X     if (awi->state & ST_ICON) {
  799. X          from = awi->icon;
  800. X          to = (awi->frame) ? awi->frame : awi->client;
  801. X     }
  802. X     else if (awi->state & ST_WINDOW) {
  803. X          from = (awi->frame) ? awi->frame : awi->client;
  804. X          to = (awi->icon) ? awi->icon : MakeIcon(window, x, y, FALSE);
  805. X     }
  806. X     else {
  807. X          fprintf(stderr, "NewIconify: Window %x has unknown state '%x'\n",
  808. X         awi->client, awi->state);
  809. X      Leave(FALSE)
  810. X     }
  811. X     status = XGetWindowAttributes(dpy, from, &fromInfo);
  812. X     if (status == FAILURE)
  813. X          Leave(FALSE)
  814. X
  815. X     status = XGetWindowAttributes(dpy, to, &toInfo);
  816. X     if (status == FAILURE)
  817. X          Leave(FALSE)
  818. X
  819. X     /*
  820. X      * Initialize the movement variables.
  821. X      */
  822. X     init_ulx = ulx = x - (toInfo.width >> 1) - toInfo.border_width;
  823. X     init_uly = uly = y - (toInfo.height >> 1) - toInfo.border_width;
  824. X     init_lrx = lrx = x + (toInfo.width >> 1) + toInfo.border_width - 1;
  825. X     init_lry = lry = y + (toInfo.height >> 1) + toInfo.border_width - 1;
  826. X     prev_x = x;
  827. X     prev_y = y;
  828. X
  829. X     if (awi->frame && awi->state & ST_ICON) {
  830. X      storegrid_func = StoreTitleGridBox;
  831. X      storebox_func = StoreTitleBox;
  832. X     }
  833. X     else {
  834. X      storegrid_func = StoreGridBox;
  835. X      storebox_func = StoreBox;
  836. X     }
  837. X     
  838. X     /*
  839. X      * Store the box.
  840. X      */
  841. X     if (Grid)
  842. X      num_vectors = storegrid_func(box, ulx, uly, lrx, lry);
  843. X     else
  844. X      num_vectors = storebox_func(box, ulx, uly, lrx, lry);
  845. X     
  846. X     /*
  847. X      * Freeze the server, if requested by the user.
  848. X      * This results in a solid box instead of a flickering one.
  849. X      */
  850. X     if (Freeze)
  851. X      XGrabServer(dpy);
  852. X     
  853. X     /*
  854. X      * Process any outstanding events before drawing the box.
  855. X      */
  856. X     while (QLength(dpy) > 0) {
  857. X      XPeekEvent(dpy, &button_event);
  858. X      if (((XAnyEvent *)&button_event)->window == RootWindow(dpy, scr))
  859. X           break;
  860. X      GetButton(&button_event);
  861. X     }
  862. X     
  863. X     /*
  864. X      * Draw the box.
  865. X      */
  866. X     DrawBox();
  867. X     if (Freeze)
  868. X      Frozen = window;
  869. X     
  870. X     /*
  871. X      * We spin our wheels here looking for mouse movement or a change
  872. X      * in the status of the buttons.
  873. X      */
  874. X     Snatched = TRUE;
  875. X     while (TRUE) {
  876. X      
  877. X      /*
  878. X       * Check to see if we have a change in mouse button status.
  879. X       * This is how we get out of this "while" loop.
  880. X       */
  881. X      if (XPending(dpy) && !ProcessRequests(box, num_vectors) &&
  882. X          GetButton(&button_event)) {
  883. X           /*
  884. X        * Process the pending events, this sequence is the only
  885. X        * way out of the loop and the routine.
  886. X        */
  887. X           
  888. X           if ((button_event.type != ButtonPress) && 
  889. X           (button_event.type != ButtonRelease)) {
  890. X            continue; /* spurious menu event... */
  891. X           }
  892. X           
  893. X           /*
  894. X        * If we froze the server, then erase the last lines drawn.
  895. X        */
  896. X           if (Freeze) {
  897. X            DrawBox();
  898. X            Frozen = (Window)0;
  899. X            XUngrabServer(dpy);
  900. X           }
  901. X           
  902. X           /*
  903. X        * Save the mouse cursor location.
  904. X        */
  905. X           if (button_event.type == ButtonPress ||
  906. X           button_event.type == ButtonRelease) {
  907. X            mse_x = ((XButtonEvent *)&button_event)->x;
  908. X            mse_y = ((XButtonEvent *)&button_event)->y;
  909. X            break;
  910. X           }
  911. X      }
  912. X      else {
  913. X           /*
  914. X        * Continue to track the mouse until we get a change
  915. X        * in button status.
  916. X        */
  917. X           XQueryPointer(dpy, RootWindow(dpy, scr), 
  918. X                 &root, &sub_win, &root_x, &root_y, &cur_x,
  919. X                 &cur_y, &ptrmask);
  920. X           
  921. X           /*
  922. X        * If the mouse has moved, then make sure the box follows it.
  923. X        */
  924. X           if ((cur_x != prev_x) || (cur_y != prev_y)) {
  925. X            
  926. X            /*
  927. X             * If we've frozen the server, then erase the old box first!
  928. X             */
  929. X            if (Freeze)
  930. X             DrawBox();
  931. X            
  932. X            /*
  933. X             * Set the new box position.
  934. X             */
  935. X            ulx += cur_x - prev_x;
  936. X            uly += cur_y - prev_y;
  937. X            lrx += cur_x - prev_x;
  938. X            lry += cur_y - prev_y;
  939. X            
  940. X            /*
  941. X             * Calculate the vectors for the new box.
  942. X             */
  943. X            
  944. X            if (Grid)
  945. X             num_vectors = storegrid_func(box, ulx, uly, lrx,
  946. X                             lry);
  947. X            else
  948. X             num_vectors = storebox_func(box, ulx, uly, lrx, lry);
  949. X            
  950. X            /*
  951. X             * Draw the new box.
  952. X             */
  953. X            if (Freeze)
  954. X             DrawBox();
  955. X           }
  956. X           
  957. X           /*
  958. X        * Save the old box position.
  959. X        */
  960. X           prev_x = cur_x;
  961. X           prev_y = cur_y;
  962. X           
  963. X           /*
  964. X        * If server is not frozen, then draw the "flicker" box.
  965. X        */
  966. X           if (!Freeze) {
  967. X            DrawBox();
  968. X            DrawBox();
  969. X           }
  970. X      }
  971. X     }
  972. X     Snatched = FALSE;
  973. X     /*
  974. X      * If the button is not a button release of the same button pressed,
  975. X      * then abort the operation.
  976. X      */
  977. X     if ((button_event.type != ButtonRelease) ||
  978. X     (((XButtonReleasedEvent *)&button_event)->button != button)) {
  979. X      ResetCursor(button);
  980. X      ungrab_pointer();
  981. X      Leave(TRUE)
  982. X     }
  983. X     
  984. X     /*
  985. X      * If we are here we have committed to iconifying/deiconifying.
  986. X      */
  987. X     
  988. X     /*
  989. X      * Determine the coordinates of the icon or window;
  990. X      * normalize the window or icon coordinates if the user so desires.
  991. X      */
  992. X     new_w = toInfo.width;
  993. X     new_h = toInfo.height;
  994. X     bdw = toInfo.border_width;
  995. X     new_x = mse_x - (new_w >> 1) - bdw;
  996. X     new_y = mse_y - (new_h >> 1) - bdw;
  997. X     if ((NIcon && awi->state & ST_WINDOW) || (NWindow && awi->state & ST_ICON)) {
  998. X      if (new_x < 0) new_x = 0;
  999. X      if (new_y < 0) new_y = 0;
  1000. X      if ((new_x - 1 + new_w + (bdw << 1)) > ScreenWidth) {
  1001. X           new_x = ScreenWidth - new_w - (bdw << 1) + 1;
  1002. X      }
  1003. X      if ((new_y - 1 + new_h + (bdw << 1)) > ScreenHeight) {
  1004. X           new_y = ScreenHeight - new_h - (bdw << 1) + 1;
  1005. X      }
  1006. X     }
  1007. X     if (awi->state & ST_ICON) {
  1008. X      awi->state ^= ST_ICON;
  1009. X      awi->state |= (ST_WINDOW | ST_PLACED);
  1010. X      if (!awi->frame)
  1011. X           XRemoveFromSaveSet(dpy, awi->client);
  1012. X     }
  1013. X     else if (awi->state & ST_WINDOW) {
  1014. X      awi->state ^= ST_WINDOW;
  1015. X      awi->state |= ST_ICON;
  1016. X      XAddToSaveSet(dpy, awi->client);
  1017. X     }
  1018. X     else
  1019. X      fprintf(stderr, "NewIconify: Window state got trashed!\n");
  1020. X     
  1021. X     /*
  1022. X      * Move the window into place.
  1023. X      */
  1024. X     XMoveWindow(dpy, to, new_x, new_y);
  1025. X     /*
  1026. X      * Map the icon window.
  1027. X      */
  1028. X     XMapRaised(dpy, to);
  1029. X     if (Zap) {
  1030. X      num_vectors = StoreZap(zap,
  1031. X                 fromInfo.x,
  1032. X                 fromInfo.y,
  1033. X                 fromInfo.x + fromInfo.width
  1034. X                 + (fromInfo.border_width << 1),
  1035. X                 fromInfo.y + fromInfo.height
  1036. X                 + (fromInfo.border_width << 1),
  1037. X                 ulx, uly, lrx, lry);
  1038. X      DrawZap();
  1039. X      DrawZap();
  1040. X     }
  1041. X     /*
  1042. X      * Unmap the event window.
  1043. X      */
  1044. X     XUnmapWindow(dpy, from);
  1045. X     XFlush(dpy);
  1046. X     ungrab_pointer();
  1047. X     Leave(TRUE)
  1048. X}
  1049. END_OF_awm/NewIconify.c
  1050. if test 11181 -ne `wc -c <awm/NewIconify.c`; then
  1051.     echo shar: \"awm/NewIconify.c\" unpacked with wrong size!
  1052. fi
  1053. # end of overwriting check
  1054. fi
  1055. if test -f awm/RubberBand.c -a "${1}" != "-c" ; then 
  1056.   echo shar: Will not over-write existing file \"awm/RubberBand.c\"
  1057. else
  1058. echo shar: Extracting \"awm/RubberBand.c\" \(11955 characters\)
  1059. sed "s/^X//" >awm/RubberBand.c <<'END_OF_awm/RubberBand.c'
  1060. X#ident   "%W% %G%"
  1061. X
  1062. X
  1063. X
  1064. X#ifndef lint
  1065. Xstatic char *rcsid_RubberBand_c = "$Header: RubberBand.c,v 1.1 88/06/15 15:24:56 jkh Exp $";
  1066. X#endif  lint
  1067. X
  1068. X#include "X11/copyright.h"
  1069. X/*
  1070. X *
  1071. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  1072. X *
  1073. X * Copyright 1987 by Jordan Hubbard.
  1074. X *
  1075. X *
  1076. X *                         All Rights Reserved
  1077. X *
  1078. X * Permission to use, copy, modify, and distribute this software and its
  1079. X * documentation for any purpose and without fee is hereby granted,
  1080. X * provided that the above copyright notice appear in all copies and that
  1081. X * both that copyright notice and this permission notice appear in
  1082. X * supporting documentation, and that the name of Ardent Computer
  1083. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  1084. X * pertaining to distribution of the software without specific, written
  1085. X * prior permission.
  1086. X *
  1087. X */
  1088. X
  1089. X/*
  1090. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  1091. X *
  1092. X *                         All Rights Reserved
  1093. X *
  1094. X * Permission to use, copy, modify, and distribute this software and its
  1095. X * documentation for any purpose and without fee is hereby granted,
  1096. X * provided that the above copyright notice appear in all copies and that
  1097. X * both that copyright notice and this permission notice appear in
  1098. X * supporting documentation, and that the name of Digital Equipment
  1099. X * Corporation not be used in advertising or publicity pertaining to
  1100. X * distribution of the software without specific, written prior permission.
  1101. X *
  1102. X *
  1103. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1104. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1105. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1106. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1107. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1108. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1109. X * SOFTWARE.
  1110. X */
  1111. X
  1112. X/*
  1113. X * MODIFICATION HISTORY
  1114. X *
  1115. X * 000 -- Loretta Guarino Reid, DEC Ultrix Engineering Group
  1116. X * 001 -- Ralph R. Swick, DEC/MIT Project Athena
  1117. X *      tailor to uwm; use global resources created by uwm
  1118. X */
  1119. X
  1120. X#include "awm.h"
  1121. X#include "X11/Xutil.h"
  1122. X#include "X11/cursorfont.h"
  1123. X
  1124. X#define max(a,b) ( (a) > (b) ? (a) : (b) )
  1125. X#define min(a,b) ( (a) > (b) ? (b) : (a) )
  1126. X#define abs(a) ( (a) > 0 ? (a) : -(a))
  1127. X#define makemult(a, b) ((b==1) ? (a) : (((int)((a) / (b))) * (b)) )
  1128. X
  1129. X#define DCOUNT 2
  1130. X#define PCOUNT 1 + (4 * 2 * DCOUNT)
  1131. X
  1132. X#define BW    PBorderWidth        /* pop-up window border width */
  1133. X#define IBW    PPadding        /* internal border width for pop-up */
  1134. X
  1135. XAskUser(dpy, scr, window, x, y, width, height, hints)
  1136. XDisplay *dpy;
  1137. Xint scr;
  1138. XWindow window;
  1139. Xint *x, *y, *width, *height;
  1140. XXSizeHints *hints;
  1141. X{
  1142. X     Cursor ur, ul, ll, lr;          /* cursors for rubber banding    */
  1143. X     int change_cursor = FALSE;
  1144. X     int current_cursor;
  1145. X     char *text;            /* text for prompt string       */
  1146. X     int nz;                         /* count where zeros are        */
  1147. X     int popw, poph;                 /* width and height of prompt window*/
  1148. X#define invertGC DrawGC
  1149. X     int x1, y1;                     /* location of mouse            */
  1150. X     int x2, y2;                     /* other corner of box          */
  1151. X     int rootx, rooty, mask;         /* for XQueryPointer          */
  1152. X     Window root, subw;        /* for XQueryPointer */
  1153. X     int xa = -1, ya = -1, xb = -1, yb = -1;
  1154. X     int xinc, yinc;
  1155. X     int minwidth, minheight;
  1156. X     int maxwidth, maxheight;
  1157. X     int defwidth, defheight;
  1158. X     int chosen = -1;
  1159. X     int stop = FALSE;
  1160. X     int changed = TRUE;
  1161. X     int doit = FALSE;
  1162. X     int dx, dy;
  1163. X     int delta;
  1164. X     XPoint box[PCOUNT];
  1165. X     int hsize, vsize;
  1166. X     int zero = '0';                 /* zero offset for char conversion  */
  1167. X     XEvent e;                 /* someplace to put the event   */
  1168. X     int events;                     /* what events we want.             */
  1169. X     Window pop;                     /* pop up prompt window         */
  1170. X     int i;
  1171. X     char *name;
  1172. X     int width_offset, height_offset; /* to subtract if resize increments */
  1173. X     
  1174. X     Entry("AskUser")
  1175. X     
  1176. X     if ((hints->flags & USPosition) && (hints->flags & USSize)) {
  1177. X      *x = hints->x;
  1178. X      *y = hints->y;
  1179. X      *width = hints->width;
  1180. X      *height = hints->height;
  1181. X      Leave_void
  1182. X     }
  1183. X     if (!XFetchName(dpy, window, &name)) 
  1184. X      name = "Unnamed Window";
  1185. X     
  1186. X     ur = XCreateFontCursor(dpy, XC_ur_angle);
  1187. X     ul = XCreateFontCursor(dpy, XC_ul_angle);
  1188. X     ll = XCreateFontCursor(dpy, XC_ll_angle);
  1189. X     lr = XCreateFontCursor(dpy, XC_lr_angle);
  1190. X     current_cursor = ul;
  1191. X     
  1192. X     events = ButtonPressMask | ButtonReleaseMask;
  1193. X     
  1194. X     /* 
  1195. X      * go get the mouse as soon as you can 
  1196. X      */
  1197. X     
  1198. X     while (1) {
  1199. X      int res;
  1200. X      if ((res = XGrabPointer (dpy, RootWindow(dpy, scr), FALSE, events, 
  1201. X                   GrabModeAsync, GrabModeAsync, None, ul,
  1202. X                   CurrentTime )) == GrabSuccess)
  1203. X           break;
  1204. X      sleep (1);
  1205. X     }
  1206. X     nz = strlen(name);        /* compute number of characters */
  1207. X     text = (char *)malloc( nz + 11 );
  1208. X     (void) strcpy(text, name);
  1209. X     (void) strcat(text, ": 000x000");
  1210. X     nz += 9;
  1211. X     popw = XTextWidth (PFontInfo, text, nz) + 2 * IBW;
  1212. X     poph = PFontInfo->ascent+PFontInfo->descent + 2 * IBW;
  1213. X     
  1214. X     pop = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 
  1215. X                   0, 0, popw, poph, BW, PBorder, PBackground);
  1216. X     XMapWindow (dpy, pop);
  1217. X     
  1218. X     if (hints->flags & PMinSize) {
  1219. X      minwidth = hints->min_width;
  1220. X      minheight = hints->min_height;
  1221. X     } else {
  1222. X      minwidth = 0;
  1223. X      minheight = 0;
  1224. X     }
  1225. X     if (hints->flags & PMaxSize) {
  1226. X      maxwidth = max(hints->max_width, minwidth);
  1227. X      maxheight = max(hints->max_height, minheight);
  1228. X     } else {
  1229. X      maxwidth = DisplayWidth(dpy, scr);
  1230. X      maxheight = DisplayHeight(dpy, scr);
  1231. X     }
  1232. X     if (hints->flags & PResizeInc) {
  1233. X      xinc = hints->width_inc;
  1234. X      yinc = hints->height_inc;
  1235. X     } else {
  1236. X      xinc = 1;
  1237. X      yinc = 1;
  1238. X     }
  1239. X     if (hints->flags & PSize || hints->flags & USSize) {
  1240. X      defwidth = hints->width;
  1241. X      defheight = hints->height;
  1242. X     } else if (hints->flags&PMinSize) {
  1243. X      defwidth = hints->min_width;
  1244. X      defheight = hints->min_height;
  1245. X     } else if (hints->flags&PMaxSize) {
  1246. X      defwidth = hints->max_width;
  1247. X      defheight = hints->max_height;
  1248. X     } else {
  1249. X      long dummy;
  1250. X      XGetGeometry(dpy, window, &dummy, &dummy, &dummy,
  1251. X               &defwidth, &defheight, &dummy, &dummy);
  1252. X     }
  1253. X     
  1254. X     /* until there are better WM_HINTS, we'll assume that the client's
  1255. X      * minimum width and height are the appropriate offsets to subtract
  1256. X      * when resizing with an explicit resize increment.
  1257. X      */
  1258. X     if (hints->flags & PMinSize && hints->flags & PResizeInc) {
  1259. X      width_offset = hints->min_width;
  1260. X      height_offset = hints->min_height;
  1261. X     } else
  1262. X      width_offset = height_offset = 0;
  1263. X     
  1264. X     
  1265. X     XQueryPointer (dpy, RootWindow(dpy, scr), &root, &subw, 
  1266. X            &rootx, &rooty, &x1, &y1, &mask);
  1267. X     hsize = minwidth; 
  1268. X     vsize = minheight;
  1269. X     x2 = x1+hsize; 
  1270. X     y2 = y1+vsize;
  1271. X     
  1272. X     while (stop == FALSE) {
  1273. X      if ( (xb != max (x1, x2)) || (yb != max (y1, y2))
  1274. X          ||(xa != min (x1, x2)) || (ya != min (y1, y2)) ) {
  1275. X           xa = min (x1, x2);
  1276. X           ya = min (y1, y2);
  1277. X           xb = max (x1, x2);
  1278. X           yb = max (y1, y2);
  1279. X           for ( i = 0; i < PCOUNT; i += 4) {
  1280. X                    box[i].x = xa; box[i].y = ya;
  1281. X                    if (i+1 == PCOUNT) break;
  1282. X                    box[i+1].x = xb; box[i+1].y = ya;
  1283. X                    box[i+2].x = xb; box[i+2].y = yb;
  1284. X                    box[i+3].x = xa; box[i+3].y = yb;
  1285. X           }
  1286. X           doit = TRUE;
  1287. X      }
  1288. X      if (changed) {
  1289. X           int Hsize = (hsize - width_offset) / xinc;
  1290. X           int Vsize = (vsize - height_offset) / yinc;
  1291. X           int pos = 3;
  1292. X           
  1293. X           changed = FALSE;
  1294. X           text[nz - 7] = (Hsize>99) ? (Hsize / 100 + zero)    : ' ';
  1295. X           text[nz - 6] = (Hsize>9)  ? ((Hsize / 10) % 10 + zero)  : ' ';
  1296. X           text[nz - 5] = Hsize % 10 + zero;
  1297. X           if (Vsize>99) text[nz - pos--] = Vsize / 100 + zero;
  1298. X           if (Vsize>9)  text[nz - pos--] = (Vsize / 10) % 10 + zero;
  1299. X           text[nz - pos--]     = Vsize % 10 + zero;
  1300. X           while (pos>0) text[nz - pos--] = ' ';
  1301. X           XDrawImageString(dpy, pop, PopGC, IBW, IBW+PFontInfo->ascent,
  1302. X                text, nz);
  1303. X      }
  1304. X      if (doit) {
  1305. X           XDrawLines(dpy, RootWindow(dpy, scr), invertGC, box, PCOUNT, 
  1306. X              CoordModeOrigin);
  1307. X      }
  1308. X      if (XPending(dpy) &&
  1309. X          XCheckMaskEvent(dpy, ButtonPressMask|ButtonReleaseMask, &e)) {
  1310. X           if ((chosen < 0) && (e.type == ButtonPress)) {
  1311. X            x1 = x2 = ((XButtonEvent *)&e)->x;
  1312. X            y1 = y2 = ((XButtonEvent *)&e)->y;
  1313. X            chosen = ((XButtonEvent *)&e)->button;
  1314. X            if (chosen == Button2)
  1315. X             change_cursor = TRUE;
  1316. X           }
  1317. X           else if ((e.type == ButtonRelease) &&
  1318. X                        ((((XButtonEvent *)&e)->button) == chosen)) {
  1319. X            x2 = ((XButtonEvent *)&e)->x;
  1320. X            y2 = ((XButtonEvent *)&e)->y;
  1321. X            stop = TRUE;
  1322. X           }
  1323. X           else
  1324. X            XQueryPointer (dpy, RootWindow(dpy, scr), &root, 
  1325. X                   &subw, &rootx, &rooty, &x2, &y2, &mask);
  1326. X      }
  1327. X      else        XQueryPointer (dpy, RootWindow(dpy, scr), &root, 
  1328. X                     &subw, &rootx, &rooty, &x2, &y2, &mask);
  1329. X      if (change_cursor) {
  1330. X           if ((x2 >= x1) && (y2 >= y1) &&
  1331. X           current_cursor != lr) {
  1332. X                    XChangeActivePointerGrab (dpy, events, lr, CurrentTime );
  1333. X                    current_cursor = lr;
  1334. X               }
  1335. X           else if ((x2 >= x1) && (y2 < y1) &&
  1336. X            current_cursor != ur) {
  1337. X                    XChangeActivePointerGrab (dpy, events, ur, CurrentTime );
  1338. X                    current_cursor = ur;
  1339. X           }
  1340. X           else if ((x2 < x1) && (y2 >= y1) &&
  1341. X            current_cursor != ll) {
  1342. X                    XChangeActivePointerGrab (dpy, events, ll, CurrentTime );
  1343. X                    current_cursor = ll;
  1344. X           }
  1345. X           else if ((x2 < x1) && (y2 < y1) &&
  1346. X            (current_cursor != ul)) {
  1347. X                    XChangeActivePointerGrab (dpy, events, ul, CurrentTime );
  1348. X                    current_cursor = ul;
  1349. X           }
  1350. X      }
  1351. X      if (chosen != Button2) {
  1352. X           x1 = x2;
  1353. X           y1 = y2;
  1354. X           if (chosen >= 0) {
  1355. X            x2 = defwidth;
  1356. X            if (chosen == Button1)
  1357. X             y2 = defheight;
  1358. X            else
  1359. X             y2 = (DisplayHeight(dpy, scr) - y1);
  1360. X            x2 = x1 + x2;
  1361. X            y2 = y1 + y2;
  1362. X           }
  1363. X      }
  1364. X      
  1365. X      dx = max(min(abs (x2 - x1), maxwidth), minwidth);
  1366. X      dx = makemult(dx-minwidth, xinc)+minwidth; 
  1367. X      dy = max(min(abs(y2 - y1), maxheight), minheight);
  1368. X      dy = makemult(dy-minheight, yinc)+minheight; 
  1369. X      
  1370. X      if (hints->flags & PAspect) {
  1371. X           if ((dx * hints->max_aspect.y > dy * hints->max_aspect.x)) {
  1372. X            delta = makemult((dx * hints->max_aspect.y /
  1373. X                      hints->max_aspect.x) - dy, yinc); 
  1374. X            if ((dy + delta) <= maxheight)
  1375. X             dy += delta;
  1376. X            else {
  1377. X             delta = makemult(dx - hints->max_aspect.x
  1378. X                      * dy/hints->max_aspect.y, xinc);
  1379. X             if ((dx - delta) >= minwidth)
  1380. X                  dx -= delta;
  1381. X            }
  1382. X           }
  1383. X           if (dx * hints->min_aspect.y < dy * hints->min_aspect.x) {
  1384. X            delta = makemult((hints->min_aspect.x *
  1385. X                      dy/hints->min_aspect.y) - dx, xinc);
  1386. X            if (dx + delta <= maxwidth)
  1387. X             dx += delta;
  1388. X            else {
  1389. X             delta = makemult(dy - (dx * hints->min_aspect.y /
  1390. X                        hints->min_aspect.x), yinc); 
  1391. X             if ((dy - delta) >= minheight)
  1392. X                  dy -= delta; 
  1393. X            }
  1394. X           }
  1395. X           
  1396. X      }
  1397. X      
  1398. X      if (dx != hsize) {
  1399. X           hsize = dx;
  1400. X           changed = TRUE;
  1401. X      }
  1402. X      if (dy != vsize) {
  1403. X           vsize = dy;
  1404. X           changed = TRUE;
  1405. X      }
  1406. X      if (x2 < x1)
  1407. X           x2 = x1 - dx;
  1408. X      else
  1409. X           x2 = x1 + dx;
  1410. X      
  1411. X      if (y2 < y1)
  1412. X           y2 = y1 - dy;
  1413. X      else
  1414. X           y2 = y1 + dy;
  1415. X     }
  1416. X     XUngrabPointer(dpy, CurrentTime);
  1417. X     
  1418. X     XDestroyWindow (dpy, pop);
  1419. X     XFreeCursor (dpy, ur);
  1420. X     XFreeCursor (dpy, ul);
  1421. X     XFreeCursor (dpy, lr);
  1422. X     XFreeCursor (dpy, ll);
  1423. X     free(name);
  1424. X     free(text);
  1425. X     *x = min(x1, x2);
  1426. X     *y = min(y1, y2);
  1427. X     *width = hsize;
  1428. X     *height = vsize;
  1429. X     XSync(dpy, FALSE);
  1430. X     Leave_void
  1431. X}
  1432. END_OF_awm/RubberBand.c
  1433. if test 11955 -ne `wc -c <awm/RubberBand.c`; then
  1434.     echo shar: \"awm/RubberBand.c\" unpacked with wrong size!
  1435. fi
  1436. # end of overwriting check
  1437. fi
  1438. echo shar: End of archive 6 \(of 13\).
  1439. cp /dev/null ark6isdone
  1440. MISSING=""
  1441. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  1442.     if test ! -f ark${I}isdone ; then
  1443.     MISSING="${MISSING} ${I}"
  1444.     fi
  1445. done
  1446. if test "${MISSING}" = "" ; then
  1447.     echo You have unpacked all 13 archives.
  1448.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1449. else
  1450.     echo You still need to unpack the following archives:
  1451.     echo "        " ${MISSING}
  1452. fi
  1453. ##  End of shell archive.
  1454. exit 0
  1455. Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
  1456.